<include file="Public/header"/>

<div id="app">
    <!-- sidebar -->
    <include file="Public/left"/>
    <!-- / sidebar -->
    <div class="app-content">
        <!-- start: TOP NAVBAR -->
        <include file="Public/headernav"/>
        <!-- end: TOP NAVBAR -->
        <div class="main-content">
            <div class="wrap-content container" id="container">
                <!-- start: PAGE TITLE -->
                <section id="page-title">
                    <div class="row">
                        <div class="col-sm-8">
                            <h1 class="mainTitle">{$msgtitle}</h1>
                            <span class="mainDescription">商品信息</span>
                        </div>
                    </div>
                </section>
                <!-- end: PAGE TITLE -->
                <!-- start: YOUR CONTENT HERE -->
                <div class="container-fluid container-fullw bg-white">
                    <form action="" role="form" id="form2" novalidate="novalidate" method="post">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="tabbable">
                                    <ul class="nav nav-tabs tab-padding tab-space-3 tab-blue" id="myTab4">
                                        <li class="active">
                                            <a data-toggle="tab" href="#panel_overview">
                                                商品基本信息
                                            </a>
                                        </li>
                                        <li>
                                            <a data-toggle="tab" href="#panel_edit_account">
                                                商品属性
                                            </a>
                                        </li>
                                        <li>
                                            <a data-toggle="tab" href="#shop_img">
                                                商品图片
                                            </a>
                                        </li>
                                        <li>
                                            <a data-toggle="tab" href="#promotion_set" id="aabb">
                                                促销设置
                                            </a>
                                        </li>
                                    </ul>
                                    <div class="tab-content">
                                        <div id="panel_overview" class="tab-pane fade  in active">
                                            <div class="row">
                                                <div class="col-md-8">
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品分类 <span class="symbol required"
                                                                       aria-required="true"></span>
                                                        </label>
                                                        <select class="form-control" id="cat_id" name="cat_id">
                                                            <option value="">请选择</option>
                                                            <volist name="category" id="vo">
                                                                <option value="{$vo.cat_id}"
                                                                <if condition="$data.cat_id eq $vo['cat_id']">selected
                                                                </if>
                                                                >{$vo.cat_name}</option>
                                                                <volist name="vo['tree']" id='voo'>
                                                                    <option value="{$voo.cat_id}"
                                                                    <if condition="$data.cat_id eq $voo['cat_id']">
                                                                        selected
                                                                    </if>
                                                                    >┗━{$voo.cat_name}</option>
                                                                    <volist name="voo['tree']" id='vot'>
                                                                        <option value="{$vot.cat_id}"
                                                                        <if condition="$data.cat_id eq $vot['cat_id']">
                                                                            selected
                                                                        </if>
                                                                        >&nbsp;&nbsp;&nbsp;&nbsp;┗━{$vot.cat_name}</option>
                                                                    </volist>
                                                                </volist>
                                                            </volist>
                                                        </select>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品名称 <span class="symbol required"
                                                                       aria-required="true"></span>
                                                        </label>
                                                        <input type="text" name="goods_name" value="{$data.goods_name}"
                                                               id="goods_name" placeholder="商品名称" class="form-control">
                                                    </div>

                                                    <div class="form-group">
                                                        <if condition="(!empty($_GET['id']))">
                                                            <label class="control-label">
                                                                商品货号<span class="symbol required"
                                                                          aria-required="true"></span>
                                                            </label>
                                                            <input type="text" disabled name="goods_sn"
                                                                   value="{$data.goods_sn}" id="goods_sn"
                                                                   placeholder="商品货号" class="form-control"/>
                                                        </if>

                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            品牌
                                                        </label>
                                                        <select class="form-control" id="brand_id" name="brand_id">
                                                            <option value="">请选择</option>
                                                            <volist name="brand" id="vo">
                                                                <option value="{$vo.brand_id}"
                                                                <if condition="$data.brand_id eq $vo['brand_id']">
                                                                    selected
                                                                </if>
                                                                >{$vo.brand_name}</option>
                                                            </volist>
                                                        </select>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            包邮方式
                                                        </label>
                                                        <select class="form-control" id="shipping_id"
                                                                name="shipping_id">
                                                            <option value="0">顺丰快递</option>
                                                            <volist name="shipping" id="vo">
                                                                <option value="{$vo.shipping_id}"
                                                                <if condition="$vo['shipping_id'] eq $data['shipping_id']">
                                                                    selected
                                                                </if>
                                                                >{$vo.shipping_name}</option>
                                                            </volist>
                                                        </select>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品库存<span class="symbol required"
                                                                      aria-required="true"></span>
                                                        </label>
                                                        <if condition="$data.goods_id gt 0">
                                                            <input type="text" name="goods_number"
                                                                   value="{$data.goods_number|default=" 0z"}"
                                                            id="goods_number" placeholder="商品库存" class="form-control">
                                                            <else/>
                                                            <input type="text" name="goods_number"
                                                                   value="{$data.goods_number|default=" 100"}"
                                                            id="goods_number" placeholder="商品库存" class="form-control">
                                                        </if>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品报警数量
                                                        </label>
                                                        <input type="text" name="warn_number"
                                                               value="{$data.warn_number|default=" 0"}" id="warn_number"
                                                        placeholder="商品报警数量" class="form-control">
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品重量
                                                        </label>

                                                        <div class="input-group">
                                                            <input type="text" name="goods_weight"
                                                                   value="{$data.goods_weight|default=" 0"}"
                                                            id="goods_weight" placeholder="商品重量" class="form-control">
                                                            <span class="input-group-addon">kg</span>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            进价<span class="symbol required" aria-required="true"></span>
                                                        </label>

                                                        <div class="input-group">
                                                            <span class="input-group-addon">￥</span>
                                                            <input type="text" name="purchase_price"
                                                                   value="{$data.purchase_price|default=" 0"}"
                                                            id="purchase_price" placeholder="进价" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            原价<span class="symbol required" aria-required="true"></span>
                                                        </label>

                                                        <div class="input-group">
                                                            <span class="input-group-addon">￥</span>
                                                            <input type="text" name="market_price"
                                                                   value="{$data.market_price}" id="market_price"
                                                                   placeholder="原价" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            本店售价<span class="symbol required"
                                                                      aria-required="true"></span>
                                                        </label>

                                                        <div class="input-group">
                                                            <span class="input-group-addon">￥</span>
                                                            <input type="text" name="shop_price"
                                                                   value="{$data.shop_price}" id="shop_price"
                                                                   placeholder="本店售价" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label" style="color: red;">
                                                            VIP专享价<span class="symbol required"
                                                                      aria-required="true"></span>
                                                        </label>

                                                        <div class="input-group">
                                                            <span class="input-group-addon" style="background: red;    border: 1px solid red">￥</span>
                                                            <input type="text" name="vip_price"
                                                                   value="{$data.vip_price}" id="vip_price"
                                                                   placeholder="VIP专享价" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            分享返利
                                                        </label>

                                                        <div class="input-group">
                                                            <span class="input-group-addon">￥</span>
                                                            <if condition="$data.goods_id gt 0">
                                                                <input type="text" name="share_money"
                                                                       value="{$data.share_money}" id="share_money"
                                                                       placeholder="分享返利" class="form-control">
                                                                <else/>
                                                                <input type="text" name="share_money"
                                                                       value="{$share_money}" id="share_money"
                                                                       placeholder="分享返利" class="form-control">
                                                            </if>
                                                        </div>

                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品主图<span class="symbol required"
                                                                      aria-required="true"></span>(300px*300px,图片大小不大于1M)
                                                        </label>
                                                        <br>

                                                        <div class="upload_file">
                                                            <label>
                                                                <input type="file" name="head_photo"
                                                                       class="upload_input" id="head_photo" value=""
                                                                       style="display:none;">

                                                                <div class="fileinput fileinput-new"
                                                                     data-provides="fileinput">
                                                                    <div class="fileinput-new thumbnail"
                                                                         id="show_photo">
                                                                        <img id="head_photo_src"
                                                                             src="{:U('wap/index/get_thumbs',array('auto'=>300))}?img={$data.goods_img}"
                                                                             alt="">
                                                                    </div>

                                                                </div>
                                                                点击图片上传
                                                            </label>
                                                            <input type="hidden" name="goods_img" id="photo_pic"
                                                                   value="{$data.goods_img}">
                                                        </div>

                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品关键字
                                                        </label>
                                                        <textarea id="keywords" name="keywords" class=" autosize"
                                                                  data-autosize-on="true"
                                                                  style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 100px;">{$data.keywords}</textarea>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品的简短描述<span class="symbol required"
                                                                         aria-required="true"></span>
                                                        </label>
                                                        <textarea id="goods_brief" name="goods_brief" class=" autosize"
                                                                  data-autosize-on="true"
                                                                  style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 100px;">{$data.goods_brief}</textarea>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品的详细描述<span class="symbol required"
                                                                         aria-required="true"></span>
                                                        </label>
                                                        <textarea id="goods_desc" name="goods_desc" class=" autosize"
                                                                  data-autosize-on="true"
                                                                  style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 300px;">{$data.goods_desc}</textarea>
                                                        <input type="hidden" name="msg" id="msg" value="">
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            状态
                                                        </label>

                                                        <div class="clip-radio radio-primary fa-hover Primary">
                                                            <if condition="$data.goods_id gt 0">
                                                                <input type="radio" value="1" name="is_on_sale"
                                                                       id="id_no"
                                                                <if condition="$data.is_on_sale eq 1">
                                                                    checked="checked"
                                                                </if>
                                                                >
                                                                <label for="id_no">
                                                                    上架
                                                                </label>


                                                                <input type="radio" value="0" name="is_on_sale"
                                                                       id="id_yes"
                                                                <if condition="$data.is_on_sale eq 0">
                                                                    checked="checked"
                                                                </if>
                                                                >
                                                                <label for="id_yes">
                                                                    下架
                                                                </label>
                                                                <else/>
                                                                <input type="radio" value="1" name="is_on_sale"
                                                                       id="id_no" checked="checked">
                                                                <label for="id_no">
                                                                    上架
                                                                </label>

                                                                <input type="radio" value="0" name="is_on_sale"
                                                                       id="id_yes">
                                                                <label for="id_yes">
                                                                    下架
                                                                </label>

                                                            </if>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            是否在首页显示
                                                        </label>

                                                        <div class="clip-radio radio-primary fa-hover Primary">
                                                            <input type="radio" value="1" name="is_show_index"
                                                                   id="is_show_index_yes"
                                                            <if condition="$data.is_show_index eq 1">checked</if>
                                                            />
                                                            <label for="is_show_index_yes">
                                                                是
                                                            </label>
                                                            <input type="radio" value="0" name="is_show_index"
                                                                   id="is_show_index_no"
                                                            <if condition="$data.is_show_index eq 0">checked</if>
                                                            />
                                                            <label for="is_show_index_no">
                                                                否
                                                            </label>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            是否支持货到付款
                                                        </label>

                                                        <div class="clip-radio radio-primary fa-hover Primary">
                                                            <input type="radio" value="1" name="offline"
                                                                   id="offline_yes" {$data['offline']?'checked':''}
                                                            />
                                                            <label for="offline_yes">
                                                                是
                                                            </label>
                                                            <input type="radio" value="0" name="offline" id="offline_no"
                                                                   {$data['offline']?'':'checked'}
                                                            />
                                                            <label for="offline_no">
                                                                否
                                                            </label>
                                                        </div>
                                                    </div>
                                                    <?php  if($_SESSION['topadmin'] ==1){  ?>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            审核状态
                                                        </label>

                                                        <div class="clip-radio radio-primary fa-hover Primary">
                                                            <if condition="$data.goods_id gt 0">
                                                                <input type="radio" value="1" name="is_auditing"
                                                                       id="id_nois_auditing"
                                                                <if condition="$data.is_auditing eq 1">
                                                                    checked="checked"
                                                                </if>
                                                                >
                                                                <label for="id_nois_auditing">
                                                                    已审核
                                                                </label>


                                                                <input type="radio" value="0" name="is_auditing"
                                                                       id="id_yesis_auditing"
                                                                <if condition="$data.is_auditing eq 0">
                                                                    checked="checked"
                                                                </if>
                                                                >
                                                                <label for="id_yesis_auditing">
                                                                    未审核
                                                                </label>
                                                                <else/>
                                                                <input type="radio" value="1" name="is_auditing"
                                                                       id="id_nois_auditing" checked="checked">
                                                                <label for="id_nois_auditing">
                                                                    已审核
                                                                </label>

                                                                <input type="radio" value="0" name="is_auditing"
                                                                       id="id_yesis_auditing">
                                                                <label for="id_yesis_auditing">
                                                                    未审核
                                                                </label>

                                                            </if>
                                                        </div>
                                                    </div>
                                                    <?php  }else{  ?>
                                                    <input type="hidden" value="0" name="is_auditing" id="is_auditing">
                                                    <?php  }  ?>


                                                    <div class="form-group">
                                                        <!--    <div class="checkbox clip-check check-primary">
                                                          <input <if condition="$data['is_best'] eq 1">checked="" </if> type="checkbox" value="1" name="is_best" id="is_best" >
                                                           <label for="is_best" class="control-label">
                                                               精品
                                                           </label>
                                                          </div>
                                                          <div class="checkbox clip-check check-primary">
                                                          <input <if condition="$data['is_new'] eq 1">checked="" </if> type="checkbox" value="1" name="is_new" id="is_new" >
                                                           <label for="is_new" class="control-label">
                                                               新品
                                                           </label>
                                                          </div>
                                                          <div class="checkbox clip-check check-primary">
                                                          <input <if condition="$data['is_hot'] eq 1">checked="" </if> type="checkbox" value="1" name="is_hot" id="is_hot" >
                                                           <label for="is_hot" class="control-label">
                                                               热销
                                                           </label>
                                                          </div> -->
                                                        <div class="checkbox clip-check check-primary">
                                                            <if condition="$data.goods_id gt 0">
                                                                <input
                                                                <if condition="$data['is_refund'] eq 1">checked=""</if>
                                                                type="checkbox" value="1" name="is_refund"
                                                                id="is_refund" >
                                                                <else/>
                                                                <input checked="checked" type="checkbox" value="1"
                                                                       name="is_refund" id="is_refund">
                                                            </if>
                                                            <label for="is_refund" class="control-label">
                                                                退货(售后服务退货)
                                                            </label>
                                                        </div>
                                                        <!--
                                                          <div class="checkbox clip-check check-primary">
                                                          <input <if condition="$data['is_exchange'] eq 1">checked="" </if> type="checkbox" value="1" name="is_exchange" id="is_exchange" >
                                                              <label for="is_exchange" class="control-label">
                                                                  换货返修(售后服务换货/返修)
                                                              </label>
                                                          </div>
                                                        -->
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品排序<span class="symbol required"
                                                                      aria-required="true"></span>
                                                        </label>
                                                        <input type="text" name="sort_order"
                                                               value="{$data.sort_order|default='0'}"
                                                               id="goods_number" placeholder="商品排序"
                                                               class="form-control">
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品的商家备注，仅商家可见
                                                        </label>
                                                        <textarea id="seller_note" name="seller_note" class=" autosize"
                                                                  data-autosize-on="true"
                                                                  style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 100px;">{$data.seller_note}</textarea>
                                                    </div>


                                                </div>
                                            </div>
                                        </div>

                                        <div id="panel_edit_account" class="tab-pane fade">
                                            <div class="row">
                                                <div class="col-md-10">
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            <span style="color: #EA0A0A;">*属性分享佣金设置后按属性佣金进行结算，多个按照最高属性佣金结算</span>
                                                            <br>
                                                            <br>
                                                            <span style="color: #EA0A0A;">*属性价格设置后按属性价格进行结算，多个按照最高属性价格结算</span>
                                                        </label>

                                                    </div>
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            商品类型
                                                        </label>
                                                        <select class="form-control" id="goods_type" name="goods_type">
                                                            <option value="">请选择</option>
                                                            <volist name="goods_type" id="vo">
                                                                <option value="{$vo.cat_id}"
                                                                <if condition="$data.goods_type eq $vo['cat_id']">
                                                                    selected
                                                                </if>
                                                                >{$vo.cat_name}</option>
                                                            </volist>
                                                        </select>
                                                    </div>
                                                    <div class="goods_type_html">


                                                    </div>


                                                </div>
                                            </div>
                                        </div>


                                        <div id="shop_img" class="tab-pane fade">
                                            <div class="row">
                                                <div class="col-md-8">

                                                    <label class="control-label">
                                                        商品图片<span class="symbol required" aria-required="true"></span>(300px*300px)排序由大到小排序
                                                        如果数字一样则按添加的顺序
                                                    </label>

                                                    <div class="form-group">
<span class="btn btn-success fileinput-button upload_file">

 <i class="glyphicon glyphicon-plus"></i> <span>上传文件...</span>
	<input type="file" name="files[]" class="upload_input" id="head_photo_url" multiple="">
</span>

                                                    </div>
                                                    <div class="form-group">

                                                        <br>

                                                        <div class="goods_image_url">

                                                            <volist name="good_image_url" id='vo'>
                                                                <div class="fileinput fileinput-new"
                                                                     data-provides="fileinput">
                                                                    <div class="fileinput-new thumbnail">
                                                                        <img id="head_photo_src_background"
                                                                             src="{$vo.img_url}" alt="">
                    <span style="display: block;width: 150px;float: left;margin-top: -103px;margin-left: 200px;">排序：<input
                            type="text" name="img_order[]" value="{$vo.img_order|default='0'}" placeholder="排序"
                            class="form-control valid" aria-required="true" aria-invalid="false">
                    </span>
                                                                        <button type="button"
                                                                                class="btn btn-danger delete delete_img"
                                                                                style="float: left;margin-top: -40px;margin-left: 200px;">
                                                                            <i class="glyphicon glyphicon-trash"></i>
                                                                            <span>删除</span>
                                                                        </button>
                                                                    </div>

                                                                    <input type="hidden" name="good_image_url[]"
                                                                           class="goods_image_count"
                                                                           value="{$vo.img_url}">
                                                                </div>
                                                            </volist>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- S 产品促销设置-->
                                        <div id="promotion_set" class="tab-pane fade">
                                            <div class="row">
                                                <div class="col-md-8">
                                                    <div class="form-group">
                                                        <label class="control-label">
                                                            是否促销
                                                        </label>

                                                        <div class="clip-radio radio-primary fa-hover Primary">
                                                            <input type="radio" value="1" name="is_promote"
                                                                   id="is_promote_yes" {$data['is_promote']?'checked':''}
                                                            />
                                                            <label for="is_promote_yes">
                                                                是
                                                            </label>
                                                            <input type="radio" value="0" name="is_promote"
                                                                   id="is_promote_no" {$data['is_promote']?'':'checked'}
                                                            />
                                                            <label for="is_promote_no">
                                                                否
                                                            </label>
                                                        </div>
                                                    </div>
                                                    <div class="form-group {$data['is_promote']?'':'hidden'}"
                                                         id="promote_msg_set">
                                                        <div class="form-group">
                                                            <label class="control-label">
                                                                促销价格<span class="symbol required"
                                                                          aria-required="true"></span>
                                                            </label>

                                                            <div class="input-group">
                                                                <span class="input-group-addon">￥</span>
                                                                <input type="text" name="promote_price"
                                                                       value="{$data.promote_price}" id="promote_price"
                                                                       placeholder="促销价格" class="form-control">
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="sr-only">
                                                                活动时间
                                                            </label>

                                                            <p class="input-group input-append datepicker_hour date"
                                                               data-date-format="yyyy-mm-dd hh:ii:ss">
                                                                <input type="text" class="form-control" id="star_time"
                                                                       name="promote_start_date" placeholder="活动开始时间"
                                                                       value="{$data['promote_start_date']|date='Y-m-d H:i:s',###}"
                                                                       readonly/>
									  <span class="input-group-addon"><span
                                              class="glyphicon glyphicon-th"></span></span>
                                                            </p>

                                                            <p class="input-group input-append datepicker_hour date"
                                                               data-date-format="yyyy-mm-dd hh:ii:ss">
                                                                <input type="text" class="form-control" id="end_time"
                                                                       name="promote_end_date"
                                                                       value="{$data['promote_end_date']|date='Y-m-d H:i:s',###}"
                                                                       placeholder="活动结束时间" readonly/>
									  <span class="input-group-addon"><span
                                              class="glyphicon glyphicon-th"></span></span>
                                                            </p>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label">
                                                                促销结束后是否恢复原价
                                                            </label>

                                                            <div class="clip-radio radio-primary fa-hover Primary">
                                                                <input type="radio" value="1" name="is_end_promote_sale"
                                                                       id="is_end_promote_sale_yes" {$data['is_end_promote_sale']?'checked':''}
                                                                />
                                                                <label for="is_end_promote_sale_yes">
                                                                    是
                                                                </label>
                                                                <input type="radio" value="0" name="is_end_promote_sale"
                                                                       id="is_end_promote_sale_no" {$data['is_end_promote_sale']?'':'checked'}
                                                                />
                                                                <label for="is_end_promote_sale_no">
                                                                    否
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label">
                                                                促销图片<span class="symbol required"
                                                                          aria-required="true"></span>(600px*300px)
                                                            </label>
                                                            <br>

                                                            <div class="upload_file">
                                                                <label>
                                                                    <input type="file" name="promotion_photo"
                                                                           class="upload_input" id="promotion_photo"
                                                                           value="" style="display:none;">

                                                                    <div class="fileinput fileinput-new"
                                                                         data-provides="fileinput">
                                                                        <div class="fileinput-new thumbnail">
                                                                            <img id="promotion_photo_src"
                                                                                 src="{:U('wap/index/get_thumbs',array('auto'=>300))}?img={$data.promote_img}"
                                                                                 alt="">
                                                                        </div>
                                                                    </div>
                                                                    点击图片上传
                                                                </label>
                                                                <input type="hidden" name="promote_img" id="promote_img"
                                                                       value="{$data.promote_img}">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- E 产品促销设置-->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <input type="hidden" value="{$data.goods_id}" name="goods_id">
                                <button class="btn btn-primary btn-wide pull-left" type="submit">
                                    提交 <i class="fa fa-arrow-circle-right"></i>
                                </button>
                            </div>

                            <div class="col-md-8">
                                <p>

                                </p>
                            </div>

                        </div>
                    </form>
                </div>


                <!-- end: YOUR CONTENT HERE -->
            </div>
        </div>
    </div>
    <!--  FOOTER and SETTINGS -->

    <include file="Public/footer"/>
    <!-- end: FOOTER -->
    <!-- start: OFF-SIDEBAR -->

    <!-- end: OFF-SIDEBAR -->

</div>
<!-- start: MAIN JAVASCRIPTS -->

<include file="Public/javascript"/>

<!-- end: CLIP-TWO JAVASCRIPTS -->

<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
<script src="__PUBLIC__/bootstrap/vendor/ckeditor/ckeditor.js"></script>
<script src="__PUBLIC__/bootstrap/vendor/ckeditor/adapters/jquery.js"></script>
<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.min.js"></script>
<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
<!-- start: CLIP-TWO JAVASCRIPTS -->
<!-- <script src="__PUBLIC__/bootstrap/assets/js/main.js"></script> -->
<!-- start: JavaScript Event Handlers for this page -->
<!--<script src="__PUBLIC__/bootstrap/assets/js/form-validation.js"></script>-->

<script src="__PUBLIC__/bootstrap/vendor/artDialog/artDialog.source.js?skin=default"></script>
<script src="__PUBLIC__/bootstrap/vendor/artDialog/plugins/iframeTools.source.js"></script>

<script src="__PUBLIC__/bootstrap/vendor/ajaxfileupload/ajaxfileupload.js"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('goods_desc');
</script>
<script>
    var get_city_url = "{:U('wap/index/get_city')}";
</script>
<script src="__PUBLIC__/js/common.js"></script>
<include file="Public/javascript_datepicker"/>
<script>
    jQuery(document).ready(function () {
        $('#is_promote_yes').click(function () {  //参加促销
            $('#promote_msg_set').removeClass('hidden');
        })
        $('#is_promote_no').click(function () {  //不参加促销
            $('#promote_msg_set').addClass('hidden');
        })
        function getPromoteStatus() {  //获取促销状态
            var is_promote_yes = $("input[name='is_promote']:checked").val();
            return is_promote_yes;
        }

        function getPromoteMsg(value) {   //获取促销时间,并转换成时间戳
            if (value == 'start') {
                var start_time = $('#star_time').val();
                var timestamp = Date.parse(new Date(start_time));
                return timestamp;
            }
            if (value == 'end') {
                var end_time = $('#end_time').val();
                var timestamp = Date.parse(new Date(end_time));
                return timestamp;
            }
        }

        jQuery.validator.addMethod('check_promote_price', function (value) {  //验证促销价格
            var ret = true;
            if (getPromoteStatus() == 1) {
                var shop_price = parseInt($('#shop_price').val());
                var promote_price = parseInt($('#promote_price').val());
                var reg = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                if (shop_price < promote_price) {  //促销价是否大于销售价
                    ret = false;
                }
                if (promote_price <= 0) {
                    ret = false;
                }
                if (!reg.test(promote_price)) {
                    ret = false;
                }
            }
            return ret;
        });
        jQuery.validator.addMethod('check_img', function (value) {  //验证促销图片
            var ret = true;
            if (getPromoteStatus() == 1) {
                var img_val = $('#promote_img').val();
                if (img_val.length <= 0) {
                    ret = false;
                }
            }
            return ret;
        });
        jQuery.validator.addMethod('check_start_time', function (value) { //验证开始时间
            var ret = true;
            if (getPromoteStatus() == 1) {
                var start_time = getPromoteMsg('start');
                var end_time = getPromoteMsg('end');
                if (start_time > end_time) {
                    ret = false;
                }
            }
            return ret;
        });
        jQuery.validator.addMethod('check_end_time', function (value) { //验证开始时间
            var ret = true;
            if (getPromoteStatus() == 1) {
                var end_time = getPromoteMsg('end');
                var now_time = Date.parse(new Date());
                if (end_time < now_time) {
                    ret = false;
                }
            }
            return ret;
        });
        jQuery.validator.addMethod("get_param_value", function (value) {
            var ret = true;
            ret = ue.hasContents();
            return ret;
        });
        $("#form2").validate({
            rules: {
                cat_id: "required",
                goods_name: "required",
                goods_sn: "required",
                goods_number: {
                    required: true,
                    digits: true,
                    max: 9999
                },
                purchase_price: {
                    number: true,
                    min: 0
                },
                // market_price: {
                // 	required:true,
                // 	number:true,
                // 	min:0.01
                // },
                shop_price: {
                    required: true,
                    number: true,
                    min: 0.01
                },
                share_money: {
                    number: true,
                    min: 0
                },
                promote_img: "check_img",
                goods_img: "required",
                goods_brief: "required",
                msg: "get_param_value",
                promote_price: {
                    check_promote_price: true
                },
                promote_start_date: {
                    check_start_time: true
                },
                promote_end_date: {
                    check_end_time: true
                }
            },
            messages: {
                cat_id: "请选择商品分类",
                goods_name: "请填写商品名称",
                goods_sn: "填写商品货号",
                goods_number: {
                    required: "请填写库存",
                    digits: "请填写正确的库存",
                    max: "库存最多9999"
                },
                purchase_price: {
                    number: "请填写正确的价格",
                    min: "价格不能小于0"
                },
                //market_price: {
                //  required:"请填写市场价",
                //   number:"请填写正确的价格",
                //    min:"价格不能小于0.01"
                //  },
                shop_price: {
                    required: "请填写本店售价",
                    number: "请填写正确的价格",
                    min: "价格不能小于0.01"
                },
                share_money: {
                    number: "请填写正确的返利金额",
                    min: "价格不能小于0"
                },
                promote_img: '请上传促销图片',
                goods_img: "请上传商品图片",
                goods_brief: "请输入商品的简短描述",
                msg: "请输入商品的详细描述",
                promote_price: {
                    check_promote_price: '促销价不能小于0且不能大于销售价'
                },
                promote_start_date: {
                    check_start_time: '开始时间不能大于结束时间'
                },
                promote_end_date: {
                    check_end_time: '结束时间不能小于当前时间'
                }
            }
        });
    });
</script>

<script>
    jQuery(document).ready(function () {
        //FormValidator.init();
        jQuery.validator.addMethod("byteRangeLength", function (value) {
            var dropdown = $("#dropdown").val();
            var ret = true;
            if (dropdown > 0) {
                if (!value) {
                    ret = false;
                }
            }
            return ret;
        });
        $("#dropdown").change(function () {
            var val = $(this).val();
            if (val > 0) {
                $(".menu_icons").hide();
            } else {
                $(".menu_icons").show();
            }

        });
    });
</script>
<script>
    $(document).ready(function (e) {
        ///上传商家logo
        $('.upload_file').on('change', '.upload_input', function () {
            var id = $(this).attr('id');
            if (id == 'head_photo') {
                //咯go 截取
                ajaxFileUploadview('head_photo', 'photo_pic', "{:U('admin/Imagecat/upload_ajax')}");
            } else if (id == 'promotion_photo') {
                ajaxFileUpload('promotion_photo', 'promote_img', "{:U('admin/Imagecat/upload_ajax')}");
            } else {
                var goods_length = $(".goods_image_count").length;
                if (goods_length >= 5) {
                    //	alert('图片最多上传5张');
                    layer.msg('图片最多上传5张', {icon: 5});
                    //  var dialog = art.dialog({title: false, fixed: true, padding: 0});
                    // art.dialog('这是php点点通的教程', function () {alert('你点击确定了')},function(){alert('你点击取消了');});
                    // dialog.lock().time(2).content("");
                } else {
                    ajaxFileUploadMore('url', "{:U('admin/Imagecat/upload_ajax')}");
                }
            }
        });

        $('.goods_image_url').on('click', '.delete_img', function () {
            if (confirm('您确定删除该图片？')) {
                $(this).parents('.fileinput').remove();
            }
        });


    });


    function show_head(head_file) {

        //插入数据库
        $("#head_photo_src").attr('src', head_file);
        var img = head_file.split('/');
        //  var file = '/' + img[3] + '/' + img[4] + '/' + img[5] + '/' + img[6];
        $("#photo_pic").val(head_file);
        //});
    }
    //文件上传带预览
    function ajaxFileUploadview(imgid, hiddenid, url) {

        $.ajaxFileUpload({
            url: url,
            secureuri: false,
            fileElementId: imgid,
            dataType: 'json',
            data: {name: 'logan', id: 'id'},
            success: function (data, status) {

                if (typeof (data.error) != 'undefined') {

                    if (data.error != '') {
                        layer.msg(data.error, {icon: 5});
                        //var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        //dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                    } else {

                        var resp = data.msg;
                        if (resp != '0000') {
                            layer.msg(data.error, {icon: 5});
                            //var dialog = art.dialog({title: false, fixed: true, padding: 0});
                            //dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            return false;
                        } else {

                            $('#head_photo_src').attr('src', data.imgurl);
                            $('#photo_pic').val(data.imgurl);

                            /* art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
                             title: '裁剪图片',
                             width: '605px',
                             height: '2900px'
                             });*/

                            //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                        }
                    }
                }
            },
            error: function (data, status, e) {
                layer.msg(e, {icon: 5});
                //var dialog = art.dialog({title: false, fixed: true, padding: 0});
                //dialog.time(3).content("<div class='tips'>" + e + "</div>");
            }
        })
        return false;
    }


    //文件上传带预览
    function ajaxFileUpload(imgid, hiddenid, url) {

        $.ajaxFileUpload({
            url: url,
            secureuri: false,
            fileElementId: imgid,
            dataType: 'json',
            data: {name: 'logan', id: 'id'},
            success: function (data, status) {

                if (typeof (data.error) != 'undefined') {

                    if (data.error != '') {
                        layer.msg(data.error, {icon: 5});
                        // var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        // dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                    } else {

                        var resp = data.msg;
                        if (resp != '0000') {
                            layer.msg(data.error, {icon: 5});
                            // var dialog = art.dialog({title: false, fixed: true, padding: 0});
                            // dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            return false;
                        } else {

                            $("#" + hiddenid).val(data.imgurl);
                            $("#" + imgid + '_src').attr('src', data.imgurl);
//                                  art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
//                                        title: '裁剪图片',
//                                        width: '605px',
//                                        height: '290px'
//                                    });

                            //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                        }
                    }
                }
            },
            error: function (data, status, e) {
                //var dialog = art.dialog({title: false, fixed: true, padding: 0});
                // dialog.time(3).content("<div class='tips'>" + e + "</div>");
                layer.msg(e, {icon: 5});
            }
        })

        return false;
    }
    //多文件上传带预览
    function ajaxFileUploadMore(imgid, url) {

        $.ajaxFileUpload({
            url: url,
            secureuri: false,
            fileElementId: "head_photo_" + imgid,
            dataType: 'json',
            data: {name: 'logan', id: 'id'},
            success: function (data, status) {
                if (typeof (data.error) != 'undefined') {

                    if (data.error != '') {
                        layer.msg(data.error, {icon: 5});
                        // var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        //dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                    } else {

                        var resp = data.msg;
                        if (resp != '0000') {
                            layer.msg(data.error, {icon: 5});
                            // var dialog = art.dialog({title: false, fixed: true, padding: 0});
                            // dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            return false;
                        } else {


                            var str_img = ' <div class="fileinput fileinput-new" data-provides="fileinput">'
                                    + ' <div class="fileinput-new thumbnail" id="show_photo_background">'
                                    + '   <img  src="' + data.imgurl + '" alt="" >'
                                    + '<span  style="display: block;width: 150px;float: left;margin-top: -103px;margin-left: 200px;">排序： <input type="text" name="img_order[]" value="0" placeholder="排序" class="form-control valid" aria-required="true" aria-invalid="false"></span>'
                                    + ' <button type="button" class="btn btn-danger delete delete_img"  style="float: left;margin-top: -40px;margin-left: 200px;">'
                                    + '	<i class="glyphicon glyphicon-trash"></i>'
                                    + '	<span>删除</span>'
                                    + '</button>'

                                    + '</div>'

                                    + '<input type="hidden" name="good_image_url[]"  class="goods_image_count"  value="' + data.imgurl + '">'
                                    + ' </div>';
                            $('.goods_image_url').append(str_img);
                            //  $('#photo_pic_'+imgid).val(data.imgurl);
                            //   $("#head_photo_src_"+imgid).attr('src', );
                            /*  art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
                             title: '裁剪图片',
                             width: '800px',
                             height: '400px'
                             });*/

                            //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                        }


                    }
                }
            },
            error: function (data, status, e) {
                layer.msg(e, {icon: 5});
                //var dialog = art.dialog({title: false, fixed: true, padding: 0});
                // dialog.time(3).content("<div class='tips'>" + e + "</div>");
            }
        })

        return false;
    }
    function setlatlng(longitude, latitude) {
        art.dialog.data('longitude', longitude);
        art.dialog.data('latitude', latitude);
        art.dialog.open('<?php echo U('
        Admin / Index / setmap
        '); ?>', {
            lock: false,
            title: '设置经纬度',
            width: 600,
            height: 400,
            yesText: '关闭',
            background: '#000',
            opacity: 0.87
        }
    )
        ;
    }
    $(document).ready(function (e) {
        $("#goods_type").change(function () {

            var __this = $(this);
            var cat_id = __this.val();
            if (cat_id) {
                var goods_id = $('input[name="goods_id"]').val();
                $.ajax({
                    url: "{:U('admin/goods/get_goods_attribute')}",
                    type: 'get',
                    data: {goods_id: goods_id, cat_id: cat_id},
                    dataType: 'html',
                    success: function (data) {
                        //console.log(data);
                        $('.goods_type_html').html(data);

                    }
                });
            } else {
                $('.goods_type_html').html("");
            }
        });
        $(".goods_type_html").on('click', '.add_data_attr', function () {
            var __this = $(this);
            var attr_id = __this.attr('data');
            //var __this_attr=$('.attr_id_'+attr_id);
            var __this_attr = __this.parents('.data_attrs');
            var html = __this_attr.html();
            html = '<div class="col-md-10 data_attrs">' + html + '</div>';
            html = html.replace('+', '-');
            html = html.replace('add_data_attr', 'remove_data_attr');
            __this_attr.after(html);
            var vall = __this_attr.next().find('input[name="goods_attr_id[]"]').val('');
        });
        $(".goods_type_html").on('click', '.remove_data_attr', function () {
            var __this = $(this);
            __this.parents('.data_attrs').remove();
        });
        $('#goods_type').change();
    });
</script>
<!-- end: JavaScript Event Handlers for this page -->
</body>
</html>
